home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcl
/
docs.lha
/
latex-CLTL-sty
/
more-info.txt
/
node1_mn.html
< prev
next >
Wrap
Text File
|
1991-07-02
|
3KB
|
70 lines
<H1><A ID="SECTION00100000000000000000"><tex2html_anchor_invisible_mark></A>
<A ID="CONTRL"><tex2html_anchor_mark></A><BR>
Control Structure
</H1>
<P>
Common Lisp provides a variety of special structures for organizing
programs. Some have to do with flow of control (control structures),
while others control access to variables (environment structures).
Some of these features are implemented as special forms;
others are implemented as macros, which typically expand into
complex program fragments expressed in terms of special forms
or other macros.
<P>
Function application is the primary method for construction of Lisp
programs. Operations are written as the application of a function
to its arguments. Usually, Lisp programs are written as a large collection
of small functions, each of which implements a simple operation.
These functions operate by calling one another, and so larger
operations are defined in terms of smaller ones.
Lisp functions may call upon themselves recursively,
either directly or indirectly.
<P>
<BR>
<tex2html_image_mark>#new4#
<BR>
<P>
While the Lisp language
is more applicative in style than statement-oriented, it
nevertheless provides many operations that produce side effects and
consequently requires constructs for controlling the sequencing of
side effects. The construct
<#9#>progn<#9#>, which is roughly equivalent to an Algol <#10#><B>begin</B><#10#>-<#11#><B>end</B><#11#>
block with all its semicolons, executes a number of forms sequentially,
discarding the values of all but the last.
Many Lisp control constructs
include sequencing implicitly, in which case they are said to
provide an ``implicit <#12#>progn<#12#>.''
<#3354#>implicit <#13#>progn<#13#><#3354#>
Other sequencing constructs include <#14#>prog1<#14#> and <#15#>prog2<#15#>.
<P>
For looping, Common Lisp provides the general iteration facility
<#16#>do<#16#> as well as a variety
of special-purpose iteration facilities for iterating or mapping
over various data structures.
<P>
Common Lisp provides the simple one-way conditionals <#17#>when<#17#> and <#18#>unless<#18#>,
the simple two-way conditional <#19#>if<#19#>, and the more general multi-way
conditionals such as <#20#>cond<#20#> and <#21#>case<#21#>. The choice of which form
to use in any particular situation is a matter of taste and
style.
<P>
Constructs for performing non-local exits with various scoping
disciplines are provided: <#22#>block<#22#>, <#23#>return<#23#>,
<#24#>return-from<#24#>,
<#25#>catch<#25#>, and <#26#>throw<#26#>.
<P>
The multiple-value constructs provide an efficient way for a function
to return more than one value; see <#27#>values<#27#>.
<P>